package com.jeez.common.jpa;


import com.jeez.common.jpa.parameter.Operator;
import com.jeez.common.jpa.parameter.Predicate;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.NoRepositoryBean;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

@NoRepositoryBean
public interface BaseJpaRepository<T, ID extends Serializable> extends JpaRepository<T, ID> {

	T findOne(String condition, Object... objects);

	List<T> findAll(String condition, Object... objects);

	List<T> findAll(Iterable<Predicate> predicates, Operator operator);

	List<T> findAll(Iterable<Predicate> predicates, Operator operator, Sort sort);

	Page<T> findAll(Iterable<Predicate> predicates, Operator operator, Pageable pageable);

	long count(Iterable<Predicate> predicates, Operator operator);

	List<T> findAll(String condition, Sort sort, Object... objects);

	Page<T> findAll(String condition, Pageable pageable, Object... objects);

	long count(String condition, Object... objects);

	void deleteByIds(Iterable<ID> ids);

	Class<T> getEntityClass();

	List<Map<String, Object>> nativeQuery4Map(String sql);

	@SuppressWarnings("rawtypes")
	Page<Map> nativeQuery4Map(String sql, Pageable pageable);

	Object nativeQuery4Object(String sql);

	void logicDelete(T entity);

	T update(T entity);

}
